import { IsString, IsOptional, IsEnum, IsNotEmpty, MaxLength } from 'class-validator';
import { Type } from 'class-transformer';

export class CreateScriptDto {
  @IsString()
  @IsNotEmpty()
  @MaxLength(100)
  name: string;

  @IsString()
  @IsOptional()
  @MaxLength(500)
  description?: string;

  @IsEnum(['node', 'python', 'bash'])
  type: 'node' | 'python' | 'bash';

  @IsString()
  @IsNotEmpty()
  content: string;
}

export class UpdateScriptDto {
  @IsString()
  @IsOptional()
  @MaxLength(100)
  name?: string;

  @IsString()
  @IsOptional()
  @MaxLength(500)
  description?: string;

  @IsEnum(['node', 'python', 'bash'])
  @IsOptional()
  type?: 'node' | 'python' | 'bash';

  @IsString()
  @IsOptional()
  content?: string;

  @IsString()
  @IsOptional()
  status?: string;
}

export class ExecuteScriptDto {
  @IsString()
  @IsOptional()
  args?: string;

  @IsOptional()
  parameters?: Record<string, string>;
}

export class QueryScriptDto {
  @IsOptional()
  @Type(() => Number)
  page?: number = 1;

  @IsOptional()
  @Type(() => Number)
  pageSize?: number = 10;

  @IsOptional()
  @IsString()
  name?: string;

  @IsOptional()
  @IsEnum(['node', 'python', 'bash'])
  type?: 'node' | 'python' | 'bash';

  @IsOptional()
  @IsString()
  status?: string;
}